/**
*@file hello_test.c
*@brief Test dirver module hello
*
*/
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
int main(int argc ,char *argv[])
{
	int hello_fd,i,len,code;
	
	char dev_name[]="/dev/hello3";
	//char buf1[32]="This is a test string";
	int buf1[32]={0,1,2,3,4,5,6,7,8,9};
	int buf2[32]={0};
	
	hello_fd=open(dev_name,O_WRONLY);
	if(hello_fd < 0)
		printf("Open device err\n");
	
	for ( i=32 ; i>0 ; i-=code){  
		if ((code=write(hello_fd , &buf1[32-i] , i)) != i) printf("write error! code=%d \n",code);
		else   printf("write ok! code=%d \n",code);
	}
	
	close(hello_fd);

	hello_fd = open(dev_name,O_RDONLY );

	for ( i=32 ; i>0 ; i-=code){  
		if ((code=read(hello_fd , &buf2[32-i] , i)) != i) printf("read error! code=%d \n",code);
		else   printf("read ok! code=%d \n",code);
	}
	
	for(i=0;i<10;i+=5) 
		printf("[%d]=%d [%d]=%d [%d]=%d [%d]=%d [%d]=%d\n",i,buf2[i],i+1,buf2[i+1],i+2,buf2[i+2],i+3,buf2[i+3],i+4,buf2[i+4]);
	//printf("%s\n",buf2);	
	close(hello_fd);
	
	return 0;
}

